package com.apes.fn.business.carAccident.modle;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.plugin.soe.metadata.BusinessAttributeValue;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @ClassName : CarEvaluation
 * @Description : 车险评估
 * @Author : WSJ
 * @Date: 2020-03-07 14:24
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarEvaluation.CONST_TABLE_NAME)
public class CarEvaluation extends BaseModel {
public static final String CONST_TABLE_NAME = "ser_car_evaluation";

    @Id
    @Column(name = "id", nullable = false, length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车险评估", padding = 9,prefix = "2")
    @Comment("车险评估单号")
    private String id;

    // @OneToOne(fetch = FetchType.LAZY)
    @OneToOne(optional = false)
    @JoinColumn(name = "car_accident_id",referencedColumnName = "id")
    @Comment("车险报案单")
    private CarAccident carAccident;


    @States(name = "定损方式", values = {
            @State(id = "A", name = "本店定损"),
            @State(id = "B", name = "转基地定损")
    })
    @Comment("定损方式")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fixed_Loss_Type",  referencedColumnName = "id")
    private BusinessAttributeValue fixedLossType;

    @States(name = "维修地点", values = {
            @State(id = "A", name = "本店维修"),
            @State(id = "B", name = "转基地维修")
    })
    @Comment("维修地点")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "repair_Place",  referencedColumnName = "id")
    private BusinessAttributeValue repairPlace;

    @States(name = "理赔类型", values = {
            @State(id = "A", name = "快赔"),
            @State(id = "B", name = "全部直赔"),
            @State(id = "C", name = "传统理赔"),
            @State(id = "D", name = "部分直赔")
    })
    @Comment("理赔类型")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "claim_Type",  referencedColumnName = "id")
    private BusinessAttributeValue claimType;

    @States(name = "特殊情况", values = {
            @State(id = "1", name = "待复勘现场"),
            @State(id = "2", name = "待保险公司调查"),
            @State(id = "3", name = "车辆未年审"),
            @State(id = "4", name = "老旧冷门车型"),
            @State(id = "5", name = "无"),
            @State(id = "6", name = "无车损险"),
            @State(id = "7", name = "待报废评估"),
            @State(id = "8", name = "待保险公司上门验件"),
            @State(id = "9", name = "需外出定损"),
            @State(id = "10", name = "待保险公司上门定损"),
            @State(id = "11", name = "待重开案")
    })
    @Comment("特殊情况")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "special_Case",  referencedColumnName = "id")
    private BusinessAttributeValue specialCase;

    @Comment("备注")
    @Column(name="remarks")
    private String remarks;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "base_id", referencedColumnName = "id")
    @Comment("基地")
    private Dept base;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "get_Car_Uid", referencedColumnName = "id")
    @Comment("接车员")
    private PartyRole getCarUid;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "assist_Uid", referencedColumnName = "id")
    @Comment("协助接车员")
    private PartyRole assistUid;
}
